<template>
  <div class="version-view">

    <div class="top">
      <el-button type="primary" size="mini" v-if="!isContrast" @click="isContrast = true">比较版本</el-button>
      <el-button type="primary" size="mini" v-else @click="isContrast = false">基线列表</el-button>
    </div>


    <div v-if="!isContrast">
      <el-table
        size="medium"
        :data="tableData"
        border>
        <el-table-column
          align="center"
          label="基线版本">
          <template slot-scope="scope">
            {{'基线版本' + scope.row.baseline_no}}
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="department"
          label="保存时间">
          <template slot-scope="scope">
            {{scope.row.created_at ? dateFormat1('yyyy-mm-dd',scope.row.created_at) : ""}}
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="duration"
          label="项目工期（天）">
        </el-table-column>
        <el-table-column
          align="center"
          label="计划开始时间">
          <template slot-scope="scope">
            {{scope.row.plan_start_time ? dateFormat1('yyyy-mm-dd',scope.row.plan_start_time) : ""}}
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          label="计划结束时间">
          <template slot-scope="scope">
            {{scope.row.plan_end_time ? dateFormat1('yyyy-mm-dd',scope.row.plan_end_time) : ""}}
          </template>
        </el-table-column>
      </el-table>
    </div>


    <div v-else>
      <version-contrast :list="tableData"></version-contrast>
    </div>

  </div>
</template>

<script>
  import versionContrast from "./versionContrast";

    export default {
        name: "index",
        components:{versionContrast},
        props:{
            datas:{
                type:Object,
                default:function () {
                    return{}
                }
            }
        },
        data:function () {
            return{
                tableData:[],
                isContrast:false,
            }
        },
        mounted:function(){
            this.getListData()
        },
        methods:{
            getListData:function(){
                this.$api.PROJECT_START_BASELINE_LIST(this.datas.id).then(res=>{
                    if (res.code == 200){
                        this.tableData = res.data;
                    }else {
                        this.$message.error(res.msg)
                    }
                })
            },
            contrastClick:function () {

            }
        }
    }
</script>

<style lang="scss" scoped>
  @import "@/assets/scss/views/projectManagement/list/details/versionView.scss";
</style>
